#include "EditorRegion.hpp"

EditorRegion::EditorRegion(){
    width = height = 0;
	regionLabel = 0;
}

EditorRegion::EditorRegion(int tx, int ty, unsigned short w, unsigned short h):Region(tx, ty, w, h){
    width = w;
    height = h;
	regionLabel = 0;
}

void EditorRegion::setArea(int tx, int ty, unsigned short tw, unsigned short th){
    Region::setArea(tx, ty, tw, th);
    width = tw;
    height = th;
	updateLabel();
}

void EditorRegion::updateLabel(){
	if(regionLabel){
		regionLabel->setString(name + std::string(" ") + StringHelper::itos(width) + "x" + StringHelper::itos(height) +
            " at (" + StringHelper::itos(x) + "," + StringHelper::itos(y) + ")");
	}
}

void EditorRegion::setScript(std::string s){
	strcpy(script, s.c_str());
}

/**
 * Draw this Region
 */
void EditorRegion::draw(sf::RenderTarget& target, sf::RenderStates states) const{
    //Initialize draw rectangle.
    sf::RectangleShape regionBox;
	regionBox.setOutlineThickness(1.0);
	regionBox.setFillColor(sf::Color(0, 255, 0, 60));
	regionBox.setOutlineColor(sf::Color::Red);
	regionBox.setSize(sf::Vector2f(width, height));

    target.draw(regionBox, states);
}

void EditorRegion::bind(lua_State* luaState){

}

void EditorRegion::push(lua_State* luaState){

}

EditorRegion::~EditorRegion(){
	if(regionLabel){
		regionLabel = 0;
	}
}